﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using secondhand.L2busslogic;
using secondhand.L1database;
using secondhand.L3object;

namespace secondhand.L4view
{
    public partial class yonghu_login : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            Session["login"] = "";
        }
        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            if (TextBox1.Text.Length == 0)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('账号不能为空 ');</script>");
                return;

            }
            if (TextBox2.Text.Length == 0)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('密码不能为空 ');</script>");
                return;

            }
            userOB mydd = new userOB();
            mydd = userBL.Getwordsingle(TextBox1.Text.Trim());
            if (mydd.user_name.Trim() == "访问数据库不成功！")
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('没有该用户 ');</script>");
                return;
            }
            if (mydd.user_name == TextBox1.Text && mydd.pass_word == TextBox2.Text)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('登录成功 ');</script>");
                Session["login"] = TextBox1.Text;
                Response.Redirect("~/L4View/yonghu/yonghu_person_info.aspx");
                return;
            }
            if ((mydd.user_name == TextBox1.Text && mydd.pass_word != TextBox2.Text) || (mydd.user_name != TextBox1.Text && mydd.pass_word == TextBox2.Text))
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('用户名或密码错误 ');</script>");
                TextBox1.Text = " ";
                TextBox2.Text = " ";
                return;
            }
        }

    }
}